/*
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package au.com.domlogic.helloPVCWorld.builder;

import au.com.domlogic.pvc.core.element.ElementMoldBuilder;
import au.com.domlogic.pvc.xhtml.element.H1ElementMold;
import au.com.domlogic.pvc.xhtml.element.IElementMold;
import au.com.domlogic.pvc.xhtml.element.SpanElementMold;

/**
 * This builder can buildElementModel a Hello World Heading and thats it!  He's not a very
 * skilled builder.  The benefit of putting the logic in a builder is that the
 * code can be cleanly reused and that it modularizes the code by encapsulating
 * the heading rendering logic in a class.
 *
 * This is a design decision and may not suit all scenarios particularly where
 * the content is likely to change regularly.  In such a case, it would be
 * preferable to have a more configurable builder which can be configured from
 * a controller with access to dao or service for the config or have a factory
 * provide an implementation somehow....Spring Framework?
 *
 * @author Domenic Figliomeni
 */
public class HelloWorldHeadingMoldBuilder implements ElementMoldBuilder {

    public HelloWorldHeadingMoldBuilder() {
    }

    @Override
    public H1ElementMold buildElementMold() {
        H1ElementMold heading = new H1ElementMold().addComponentMold(
                new SpanElementMold().setContent("Hello ")).addComponentMold(
                new IElementMold().setContent("World!"));
        return heading;
    }
}
